package ControlLayer;

import ModelLayer.*;
import DBLayer.*;
import java.util.ArrayList;
/**
 */
public class CtrCustomer {
   

        public CtrCustomer() {

        }
        
        
        public void NewCustomer(Customer cusObj)
      {
           IFDBCustomer dbCus = new DBCustomer();
           dbCus.insertCustomer(cusObj);
      }
        
       public void updateCustomer(String fname, String lname, String address, int zipCode, int phoneNo, String city, String email, double discount, int id)
        {
        IFDBCustomer dbCus = new DBCustomer();       
        Customer cus = new Customer();
        
        cus.setFname(fname);
        cus.setLname(lname);
        cus.setAddress(address);
	cus.setZipCode(zipCode);
	cus.setPhoneNo(phoneNo);
        cus.setCity(city);
        cus.setEmail(email);
        cus.setDiscount(discount);
        cus.setId(id);

        
        dbCus.updateCustomer(cus);  
        }

       
        // Cid Står for CostumerID fra database modelen.
     public void deleteCustomer(int Cid) 
     {
	IFDBCustomer dbCus = new DBCustomer();
	 dbCus.deleteCustomer(Cid);
     }


     public Customer findByName(String fname)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomerByName(fname, true);
    }

      public Customer findById(int Cid)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomer(Cid, true);
    }

      public Customer findByPhoneNo(int phoneNo)
    {
        IFDBCustomer dbCus = new DBCustomer();
        return dbCus.findCustomer( phoneNo, true);
    }

    public ArrayList GetAllCustomers()
    {
      IFDBCustomer dbCus = new DBCustomer();
      ArrayList allCus = new ArrayList();
      allCus = dbCus.getAllCustomer(false);
      return allCus;
    }

    public int getMaxID()
    {
        IFDBCustomer dbCus = new DBCustomer();
        int id = dbCus.MaxID();
        return id;
    }
            
    
     public int getAllKundeNum()
   {
       IFDBCustomer dbCus = new DBCustomer();
       int id = dbCus.Antal();
       return id;
                
      }


}
